import {API_HOST,API_PROXY} from "../config.js"
export function compareTimestamp(timestamp){
	const currentTime=new Date().getTime();
	const timeDiff=currentTime-timestamp;
	if(timeDiff<1000*60){
		return '1分钟内'
	}else if(timeDiff<1000*60*60){
		return Math.floor(timeDiff/(1000*60))+'分钟'
	}else if(timeDiff<1000*60*60*24){
		return Math.floor(timeDiff/(1000*60*60))+'小时'
	}
	else if(timeDiff<1000*60*60*24*30){
		return Math.floor(timeDiff/(1000*60*60*24))+'天'
		
	}
	else if(timeDiff<1000*60*60*24*30*3){
		return Math.floor(timeDiff/(1000*60*60*24*30))+'月'
		
	}else{
		return "很久"
		
	}
	
}
export const packApiUrl = (url = '') => {
  if (url.slice(0, 4) === 'http') return url
  else return `${API_HOST}${API_PROXY}${url}`
}

export function gotoHome(){
	uni.showModal({
		title:'提示',
		content:"页面有误将返回首页",
		showCancel:false,
		success:(res)=>{
			if(res.confirm){
				uni.reLaunch({
					url:"/pages/index/index"
				})
			}
		}
	})
}